module("UI.Windows.NewGameLoobyWin", package.seeall)


local UIWindow = require("UI.UIWindow").UIWindow
local UIUtility = require("UI.Utility")
local UIWinMgr = require("UI.UIWinMgr").UIWinMgr
local atools = require("StringTool").StringTool
local json = require("cjson")
local DOTweenMgr = require("UI.DOTweenMgr")

local GameObject = UnityEngine.GameObject



NewGameLoobyWin = UIWindow:new()

NewGameLoobyWin.name = "NewGameLoobyWin" --窗体名字

function NewGameLoobyWin:Init()
    local t                     = self.Container.transform

    --心跳
    self.heartbeat_count_id     = CountDownMgr.Instance:CreateCountDown(999999, 30, function()
        require("NetWork.NetHttp").SendGetRequest("/byr/heartbeat", function(ok, data)
            if ok then
                --print("心跳成功" .. stringify(data))
            end
        end)
    end, self.ggEnd)

    self.balance_data           = {}

    self.shop_tixian_qbye_lable = UIUtility.FindContorl("UILabel", "shop_tixian_qbye_lable", t)
    self.shop_tixian_syed_lable = UIUtility.FindContorl("UILabel", "shop_tixian_syed_lable", t)

    --首页金额
    self.shouye_ye_update_btn   = UIUtility.GetChildTransform("shouye_ye_update_btn", t, true)
    UIHelper.BindUIEvnet("Click", function()
        if self.balance_data.gameBalance < 100 then
            self:xiaFenUpdate()
        else
            self:UpdateUserInfo(1)
        end
        -- self:UpdateUserInfo(1)

        if self.currentTween then
            self.currentTween:Kill()
            self.currentTween = nil
        end
        self.currentTween = DOTweenMgr.DTDORot360(
            self.shouye_ye_update_btn.transform,
            Vector3(0, 0, 360),
            1,
            1,
            function() end,
            function() end,
            0
        )
    end, UIUtility.GetChildTransform("shouye_ye_update_btn", t, true).gameObject)

    --代理金额
    self.daili_jine_btn = UIUtility.GetChildTransform("daili_jine_btn", t, true)
    UIHelper.BindUIEvnet("Click", function()
        self:UpdateUserInfo(1)

        if self.currentTween then
            self.currentTween:Kill()
            self.currentTween = nil
        end
        self.currentTween = DOTweenMgr.DTDORot360(
            self.daili_jine_btn.transform,
            Vector3(0, 0, 360),
            1,
            1,
            function() end,
            function() end,
            0
        )
    end, self.daili_jine_btn.gameObject)

    --打开首冲页面
end

--初始化界面
function NewGameLoobyWin:OnShow()
    UIWinMgr:OpenWindow("ActivityShouChongWin")
    local t           = self.Container.transform

    self.isShow       = true
    local SoundModule = require("Module.SoundModule").SoundModule
    SoundModule:Init()



    if self.moveCountID ~= nil then
        CountDownMgr.Instance:RemoveCountDown(self.moveCountID, false)
    end
    self.isAdvFistMove = true;
    self.moveCountID = CountDownMgr.Instance:CreateCountDown(999999, 4, self.ggmove, self.ggEnd)

    SoundModule:SetBGM("Sound/BGM/app_bg")
    --  SoundModule:SetAllBgVolume(0)

    -- require("Module.SoundModule").SoundModule:SetAllBgVolume(UnityEngine.PlayerPrefs.GetString("SetSound") == "1" and
    -- 0.2 or 0)



    self.jifen_text    = UIUtility.FindContorl('UILabel', "jifen_text", t)
    self.userName_text = UIUtility.FindContorl('UILabel', "userName_text", t)

    --
    self.jackpot_grid  = UIUtility.GetChildTransform("jackpot_grid", t, true)
    self.jackpot_item  = {}
    for i = 1, self.jackpot_grid.transform.childCount do
        self.jackpot_item[i] = self.jackpot_grid.transform:GetChild(i - 1).transform:GetComponent("UISprite")
    end
    --获取游戏奖池
    require("NetWork.NetHttp").SendGetRequest("/byr/pot/amount", function(ok, data)
        if ok then
            for i = 1, #tostring(data.data) do
                self.jackpot_item[i].spriteName = "num_1_" .. string.sub(data.data, i, i)
            end
        else
            print("获取游戏奖池失败" .. stringify(data))
        end
    end)




    self.toggle_shouye              = UIUtility.FindContorl("UIToggle", "toggle_shouye", t)

    self.testImg                    = UIUtility.FindContorl("UITexture", "testImg", t)

    -- 首页
    self.toggle_shouye              = UIUtility.FindContorl("UIToggle", "toggle_shouye", t)

    -- 商城
    self.toggle_shangcheng          = UIUtility.FindContorl("UIToggle", "toggle_shangcheng", t)
    -- 消息
    self.toggle_xiaoxi              = UIUtility.FindContorl("UIToggle", "toggle_xiaoxi", t)
    -- 代理
    self.toggle_daili               = UIUtility.FindContorl("UIToggle", "toggle_daili", t)
    -- 我的
    self.toggle_wode                = UIUtility.FindContorl("UIToggle", "toggle_wode", t)

    self.DowntoggleArr              = { self.toggle_shouye, self.toggle_shangcheng, self
        .toggle_xiaoxi, self.toggle_daili,
        self
            .toggle_wode }

    self.shouyePanel                = UIUtility.GetChildTransform("shouyePanel", t, true)
    self.shopPanel                  = UIUtility.GetChildTransform("shopPanel", t, true)
    self.xiaoxiPanel                = UIUtility.GetChildTransform("xiaoxiPanel", t, true)
    self.dailiPanel                 = UIUtility.GetChildTransform("dailiPanel", t, true)
    self.wodePanel                  = UIUtility.GetChildTransform("wodePanel", t, true)

    self.allGamePanel               = { self.shouyePanel, self.shopPanel, self.xiaoxiPanel, self
        .dailiPanel, self
        .wodePanel }

    -- 热门
    self.toggle_remen               = UIUtility.FindContorl("UIToggle", "toggle_remen", t)
    self.toggle_remen.value         = true
    -- 视讯
    self.toggle_shixun              = UIUtility.FindContorl("UIToggle", "toggle_shixun", t)
    -- 捕鱼
    self.toggle_buyu                = UIUtility.FindContorl("UIToggle", "toggle_buyu", t)
    -- 棋牌
    self.toggle_qipai               = UIUtility.FindContorl("UIToggle", "toggle_qipai", t)
    -- 电玩
    self.toggle_dianzi              = UIUtility.FindContorl("UIToggle", "toggle_dianzi", t)
    -- 彩票
    self.toggle_caipiao             = UIUtility.FindContorl("UIToggle", "toggle_caipiao", t)
    -- 体育
    self.toggle_tiyu                = UIUtility.FindContorl("UIToggle", "toggle_tiyu", t)

    --
    self.right_toggle_remen         = UIUtility.FindContorl("UIToggle", "right_toggle_remen", t)
    self.right_toggle_shoucang      = UIUtility.FindContorl("UIToggle", "right_toggle_shoucang", t)
    self.tete                       = UIUtility.GetChildTransform("right_toggle_remen", t, true)

    self.right_toggle_zuijin        = UIUtility.FindContorl("UIToggle", "right_toggle_zuijin", t)
    self.right_panel_zuijin_sv_grid = UIUtility.FindContorl("UIGrid", "right_panel_zuijin_sv_grid", t)

    self.right_panel_remem          = UIUtility.GetChildTransform("right_panel_remen", t, true)
    self.right_panel_zuijin         = UIUtility.GetChildTransform("right_panel_zuijin", t, true)
    self.right_panel_shoucang       = UIUtility.GetChildTransform("right_panel_shoucang", t, true)

    self.right_panel_shoucang_Grid  = UIUtility.FindContorl("UIGrid", "right_panel_shoucang_Grid", t)


    self.all_rm_zj_sc_arr = { self.right_toggle_remen, self.right_toggle_zuijin, self.right_toggle_shoucang }
    self.all_rm_zj_sc_panel = { self.right_panel_remem, self.right_panel_zuijin, self.right_panel_shoucang }

    self.all_rm_zj_sc_index = 0

    for i = 1, #self.all_rm_zj_sc_arr do
        self.all_rm_zj_sc_arr[i].onChange:Clear()
        self.all_rm_zj_sc_arr[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.all_rm_zj_sc_arr[i].value then
                self.all_rm_zj_sc_index = i
                for j = 1, #self.all_rm_zj_sc_panel do
                    self.all_rm_zj_sc_panel[j].gameObject:SetActive(i == j)
                end
                if i == 1 then
                    for m = 1, #self.UpToggleArr do
                        self.UpToggleArr[m].value = m == 1
                    end
                    for j = 2, self.gameGrid.transform.childCount do
                        local curItem = self.gameGrid.transform:GetChild(j - 1)
                        if i == 1 then
                            curItem.gameObject:SetActive(true)
                        else
                            curItem.gameObject:SetActive(atools:Split(curItem.gameObject.name, "|")[1] == (i - 1) .. "")
                        end
                    end
                    --重置Grid
                    self.gameGrid.repositionNow = true
                    self.gameGrid:Reposition()
                    self.gameScrollbar.value = 0
                end

                if i == 2 then
                    for m = 1, #self.UpToggleArr do
                        self.UpToggleArr[m].value = m == 1
                    end


                    for j = 1, self.right_panel_zuijin_sv_grid.transform.childCount do
                        GameObject.Destroy(self.right_panel_zuijin_sv_grid.transform:GetChild(self
                            .right_panel_zuijin_sv_grid.transform.childCount - j).gameObject)
                    end

                    --在创建
                    local recentGame = UnityEngine.PlayerPrefs.GetString("recentGame", "")
                    local recentGameArr = atools:Split(recentGame, "&")
                    for m = 1, #recentGameArr do
                        local newItem = UIUtility.GetChildTransform(recentGameArr[m], self.gameGrid.transform, true)
                        if newItem ~= nil then
                            local item = GameObject.Instantiate(newItem)
                            item.gameObject:SetActive(true)
                            item.transform.parent = self.right_panel_zuijin_sv_grid.transform
                            item.transform.localScale = Vector3.one
                            item.transform.localPosition = Vector3.zero
                            item.transform.localEulerAngles = Vector3.zero
                            item.gameObject.name = newItem.name
                            local itemname = atools:Split(item.gameObject.name, "|")
                            local shoucang_tip = UIUtility.FindContorl("UIToggle", "shoucang_tip", item.transform)

                            shoucang_tip.onChange:Clear()
                            shoucang_tip.onChange:Add(UIHelper.CreateEventDelegate(function()
                                if shoucang_tip.value then
                                    UnityEngine.PlayerPrefs.SetString(item.gameObject.name, "1") --缓存帐号
                                    UIUtility.GetChildTransform(item.gameObject.name, self.gameGrid.transform, true).transform:GetChild(2)
                                    .transform:GetComponent("UIToggle").value = true
                                else
                                    UnityEngine.PlayerPrefs.SetString(item.gameObject.name, "0") --缓存帐号
                                    UIUtility.GetChildTransform(item.gameObject.name, self.gameGrid.transform, true).transform:GetChild(2)
                                    .transform:GetComponent("UIToggle").value = false
                                end
                            end, shoucang_tip.gameObject))

                            shoucang_tip.value = UnityEngine.PlayerPrefs.GetString(item.gameObject.name, "0") == "1"


                            UIHelper.BindUIEvnet("Click", function()
                                --进入游戏
                                UIWinMgr:OpenMask()
                                -- require("NetWork.NetHttp").SendGetRequest(
                                --     "/game/api/upScore?gamePlatformId=" .. itemname[3],
                                --     function(ok, data)
                                --         if ok then
                                            require("NetWork.NetHttp").SendGetRequest(
                                                "/game/api/loginWithScore?gamePlatformId=" ..
                                                itemname[3] ..
                                                "&gameIndex=" .. itemname[4] .. "&gameType=" ..
                                                itemname[1],
                                                function(ok, __data)
                                                    if ok then
                                                        --关闭游戏音效
                                                        local SoundModule = require("Module.SoundModule").SoundModule
                                                        SoundModule:SetAllBgVolume(0)

                                                        local WebViewWindow = UIWinMgr:OpenWindow("WebViewKefuWindow")
                                                        --   print("登录成功" .. __data.data.loginUrl)


                                                        WebViewWindow.gamePlatformId = itemname[3]
                                                        WebViewWindow.gameType = itemname[1]
                                                        WebViewWindow:SetUrl(__data.data.loginUrl)
                                                        WebViewWindow:SetAudioMuted(false)
                                                    else
                                                        UIWinMgr:CloseMask()
                                                        UIWinMgr:OpenTextNotice(__data.msg)
                                                    end
                                                    --上分
                                                end)
                                    --     else
                                    --         UIWinMgr:CloseMask()
                                    --         UIWinMgr:OpenTextNotice(data.msg)
                                    --         print("上分失败" .. stringify(data))
                                    --     end
                                    --     --上分
                                    -- end)
                            end, item.gameObject)
                        end
                    end
                    self.right_panel_zuijin_sv_grid.repositionNow = true
                    self.right_panel_zuijin_sv_grid:Reposition()
                end
                if i == 3 then
                    for m = 1, #self.UpToggleArr do
                        self.UpToggleArr[m].value = m == 1
                    end
                    for i = 1, self.right_panel_shoucang_Grid.transform.childCount do
                        GameObject.Destroy(self.right_panel_shoucang_Grid.transform:GetChild(i - 1).gameObject)
                    end
                    --在创建
                    for m = 1, self.gameGrid.transform.childCount do
                        local newItem = self.gameGrid.transform:GetChild(m - 1).gameObject
                        local soucangToggle = UIUtility.FindContorl("UIToggle", "shoucang_tip", newItem.transform)
                        if newItem ~= nil and soucangToggle ~= nil and soucangToggle.value == true then
                            local item = GameObject.Instantiate(newItem)
                            item.gameObject:SetActive(true)
                            item.transform.parent = self.right_panel_shoucang_Grid.transform
                            item.transform.localScale = Vector3.one
                            item.transform.localPosition = Vector3.zero
                            item.transform.localEulerAngles = Vector3.zero
                            item.gameObject.name = newItem.gameObject.name
                            local itemname = atools:Split(item.gameObject.name, "|")

                            local shoucang_tip = UIUtility.FindContorl("UIToggle", "shoucang_tip", item.transform)
                            shoucang_tip.onChange:Clear()
                            shoucang_tip.onChange:Add(UIHelper.CreateEventDelegate(function()
                                if shoucang_tip.value then
                                    UnityEngine.PlayerPrefs.SetString(item.gameObject.name, "1") --缓存帐号
                                    UIUtility.GetChildTransform(item.gameObject.name, self.gameGrid.transform, true).transform:GetChild(2)
                                    .transform:GetComponent("UIToggle").value = true
                                else
                                    UnityEngine.PlayerPrefs.SetString(item.gameObject.name, "0") --缓存帐号
                                    UIUtility.GetChildTransform(item.gameObject.name, self.gameGrid.transform, true).transform:GetChild(2)
                                    .transform:GetComponent("UIToggle").value = false
                                end
                            end, shoucang_tip.gameObject))

                            shoucang_tip.value = UnityEngine.PlayerPrefs.GetString(item.gameObject.name, "0") == "1"

                            UIHelper.BindUIEvnet("Click", function()
                                --进入游戏
                                UIWinMgr:OpenMask()
                                -- require("NetWork.NetHttp").SendGetRequest(
                                --     "/game/api/upScore?gamePlatformId=" .. itemname[3],
                                --     function(ok, data)
                                --         if ok then
                                            require("NetWork.NetHttp").SendGetRequest(
                                                "/game/api/loginWithScore?gamePlatformId=" ..
                                                itemname[3] ..
                                                "&gameIndex=" .. itemname[4] .. "&gameType=" ..
                                                itemname[1],
                                                function(ok, __data)
                                                    if ok then
                                                        --关闭游戏音效
                                                        local SoundModule = require("Module.SoundModule").SoundModule
                                                        SoundModule:SetAllBgVolume(0)

                                                        local WebViewWindow = UIWinMgr:OpenWindow("WebViewKefuWindow")
                                                        --   print("登录成功" .. __data.data.loginUrl)


                                                        WebViewWindow.gamePlatformId = itemname[3]
                                                        WebViewWindow.gameType = itemname[1]
                                                        WebViewWindow:SetUrl(__data.data.loginUrl)
                                                        WebViewWindow:SetAudioMuted(false)
                                                    else
                                                        UIWinMgr:CloseMask()
                                                        UIWinMgr:OpenTextNotice(__data.msg)
                                                    end
                                                    --上分
                                                end)
                                    --     else
                                    --         UIWinMgr:CloseMask()
                                    --         UIWinMgr:OpenTextNotice(data.msg)
                                    --         print("上分失败" .. stringify(data))
                                    --     end
                                    --     --上分
                                    -- end)
                            end, item.gameObject)
                        end
                    end
                    self.right_panel_shoucang_Grid.repositionNow = true
                    self.right_panel_shoucang_Grid:Reposition()
                end
            end
        end, self.all_rm_zj_sc_arr[i].gameObject))
    end


    self.tete.transform:GetComponent("UIToggle").value = false

    self.aaa                                           = 336
    self.ea                                            = #tostring(self.aaa)
    self.aae                                           = string.sub(336, 3, 3)

    self.UpToggleArr                                   = { self.toggle_remen, self.toggle_shixun, self.toggle_buyu, self
        .toggle_qipai,
        self.toggle_dianzi, self.toggle_tiyu, self.toggle_caipiao }
    self.gameItem                                      = UIUtility.GetChildTransform("gameItem", t, true)
    self.gameGrid                                      = UIUtility.FindContorl("UIGrid", "gameGrid", t)

    for i = 1, #self.UpToggleArr do
        self.UpToggleArr[i].onChange:Clear()

        self.UpToggleArr[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.UpToggleArr[i].value then
                if self.all_rm_zj_sc_index == 1 then
                    for j = 2, self.gameGrid.transform.childCount do
                        local curItem = self.gameGrid.transform:GetChild(j - 1)
                        if i == 1 then
                            curItem.gameObject:SetActive(true)
                        else
                            curItem.gameObject:SetActive(atools:Split(curItem.gameObject.name, "|")[1] == (i - 1) .. "")
                        end
                    end
                    --重置Grid
                    self.gameGrid.repositionNow = true
                    self.gameGrid:Reposition()
                    self.gameScrollbar.value = 0
                elseif self.all_rm_zj_sc_index == 2 then
                    for j = 1, self.right_panel_zuijin_sv_grid.transform.childCount do
                        local curItem = self.right_panel_zuijin_sv_grid.transform:GetChild(j - 1)
                        if i == 1 then
                            curItem.gameObject:SetActive(true)
                        else
                            curItem.gameObject:SetActive(atools:Split(curItem.gameObject.name, "|")[1] == (i - 1) .. "")
                        end
                    end
                    --重置Grid
                    self.right_panel_zuijin_sv_grid.repositionNow = true
                    self.right_panel_zuijin_sv_grid:Reposition()
                elseif self.all_rm_zj_sc_index == 3 then
                    for j = 1, self.right_panel_shoucang_Grid.transform.childCount do
                        local curItem = self.right_panel_shoucang_Grid.transform:GetChild(j - 1)
                        if i == 1 then
                            curItem.gameObject:SetActive(true)
                        else
                            curItem.gameObject:SetActive(atools:Split(curItem.gameObject.name, "|")[1] == (i - 1) .. "")
                        end
                    end
                    --重置Grid
                    self.right_panel_shoucang_Grid.repositionNow = true
                    self.right_panel_shoucang_Grid:Reposition()
                end
            end
        end, self.UpToggleArr[i].gameObject))
    end

    --奖池 效果




    self.gameScrollView = UIUtility.FindContorl("UIScrollView", "gameScrollView", t)
    self.gameScrollbar = UIUtility.FindContorl("UIScrollBar", "gameScrollbar", t)

    self.allGameList_data = {}
    --获取游戏列表
    require("NetWork.NetHttp").SendGetRequest("/game/game/index/list?pageSize=130", function(ok, data)
        if ok then
            -- ["sort"] = 2,
            -- ["gameType"] = 4,
            -- ["gamePlatformId"] = 4,
            -- ["gameName"] = "富贵金蟾",
            -- ["inCount"] = 0,
            -- ["state"] = 1,
            -- ["gameIndex"] = "5213",
            -- ["id"] = 96,
            -- ["gameIcon"] = userdata<userdata: NULL>,
            --视讯 捕鱼 棋牌 电玩 体育 彩票

            print(stringify(data))
            self.allGameList_data = data.data.list
            print("游戏列表" .. #data.data.list)
            self.all_rm_zj_sc_arr[1].value = true
            for i = 1, #data.data.list do
                if i ~= 0 then
                    local gameItem = GameObject.Instantiate(self.gameItem)
                    local gameItemData = data.data.list[i]




                    gameItem.transform.parent = self.gameGrid.transform
                    gameItem.transform.localScale = Vector3.one
                    gameItem.transform.localPosition = Vector3.zero
                    gameItem.transform.localEulerAngles = Vector3.zero
                    if gameItemData.gamePlatformId == 3 then
                        gameItem.gameObject.name = gameItemData.gameType ..
                            "|" .. gameItemData.gamePlatformId .. "_" .. gameItemData.gameIndex
                            .. "|" .. gameItemData.gamePlatformId .. "|" .. gameItemData.gameIndex
                    elseif gameItemData.gamePlatformId == 4 then
                        gameItem.gameObject.name = gameItemData.gameType ..
                            "|" .. gameItemData.gameIndex .. "_" .. gameItemData.gameName .. "_500x500_cn"
                            .. "|" .. gameItemData.gamePlatformId .. "|" .. gameItemData.gameIndex
                    elseif gameItemData.gamePlatformId == 5 then
                        gameItem.gameObject.name = gameItemData.gameType ..
                            "|" .. gameItemData.gameIndex .. "_425x425_cube_cn"
                            .. "|" .. gameItemData.gamePlatformId .. "|" .. gameItemData.gameIndex
                    elseif gameItemData.gamePlatformId == 6 then
                        gameItem.gameObject.name = gameItemData.gameType ..
                            "|" .. gameItemData.gamePlatformId .. "_" .. gameItemData.gameIndex
                            .. "|" .. gameItemData.gamePlatformId .. "|" .. gameItemData.gameIndex
                    else
                        gameItem.gameObject.name = gameItemData.gameType ..
                            "|" .. gameItemData.gameIndex .. "_425x425_cube_cn"
                            .. "|" .. gameItemData.gamePlatformId .. "|" .. gameItemData.gameIndex
                    end
                    local gameItem_icon = UIUtility.FindContorl("UITexture", "gameItem_icon", gameItem.transform)
                    local gameItem_name = UIUtility.FindContorl("UILabel", "gameItem_name", gameItem.transform)


                    gameItem_name.text = gameItemData.gameName

                    local shoucang_tip = UIUtility.FindContorl("UIToggle", "shoucang_tip", gameItem.transform)
                    shoucang_tip.onChange:Clear()
                    shoucang_tip.onChange:Add(UIHelper.CreateEventDelegate(function()
                        if shoucang_tip.value then
                            UnityEngine.PlayerPrefs.SetString(gameItem.gameObject.name, "1") --缓存帐号
                        else
                            UnityEngine.PlayerPrefs.SetString(gameItem.gameObject.name, "0") --缓存帐号
                        end
                    end, shoucang_tip.gameObject))

                    shoucang_tip.value = UnityEngine.PlayerPrefs.GetString(gameItem.gameObject.name, "0") == "1"

                    UIHelper.BindUIEvnet("Click", function()
                        --进入游戏
                         UIWinMgr:OpenMask()
                        -- require("NetWork.NetHttp").SendGetRequest(
                        --     "/game/api/upScore?gamePlatformId=" .. gameItemData.gamePlatformId,
                        --     function(ok, data)
                            --    if ok then
                                    require("NetWork.NetHttp").SendGetRequest(
                                        "/game/api/loginWithScore?gamePlatformId=" ..
                                        gameItemData.gamePlatformId ..
                                        "&gameIndex=" .. gameItemData.gameIndex .. "&gameType=" ..
                                        gameItemData.gameType,
                                        function(ok, __data)
                                            if ok then
                                                --关闭游戏音效
                                                local SoundModule = require("Module.SoundModule").SoundModule
                                                SoundModule:SetAllBgVolume(0)

                                                local WebViewWindow = UIWinMgr:OpenWindow("WebViewKefuWindow")
                                                --   print("登录成功" .. __data.data.loginUrl)


                                                WebViewWindow.gamePlatformId = gameItemData.gamePlatformId
                                                WebViewWindow.gameType = gameItemData.gameType
                                                WebViewWindow:SetUrl(__data.data.loginUrl)
                                                WebViewWindow:SetAudioMuted(false)

                                                --进入游戏 把name存入到最近游戏  &做为分割符号
                                                local recentGame = UnityEngine.PlayerPrefs.GetString("recentGame", "")
                                                if recentGame == "" then
                                                    UnityEngine.PlayerPrefs.SetString("recentGame",
                                                        gameItem.gameObject.name)
                                                else
                                                    local recentGameArr = atools:Split(recentGame, "&")
                                                    for m = 1, #recentGameArr do
                                                        if recentGameArr[m] == gameItem.gameObject.name then
                                                            break;
                                                        end
                                                        UnityEngine.PlayerPrefs.SetString("recentGame",
                                                            gameItem.gameObject.name .. "&" .. recentGame)
                                                    end
                                                end
                                            else
                                                UIWinMgr:CloseMask()
                                                UIWinMgr:OpenTextNotice(__data.msg)
                                            end
                                            --上分
                                        end)
                            --     else
                            --         UIWinMgr:CloseMask()
                            --         UIWinMgr:OpenTextNotice(data.msg)
                            --         print("上分失败" .. stringify(data))
                            --     end
                            --     --上分
                            -- end)
                    end, gameItem.gameObject)

                    --测试加载头像
                    function callBack(isOk, www)
                        if isOk then
                            gameItem_icon.mainTexture = www.texture
                            gameItem_icon.gameObject:SetActive(true)
                        end
                    end

                    if #atools:Split(gameItem.gameObject.name, "|") > 1 then
                        require("NetWork.NetHttp").WWWTexture(atools:Split(gameItem.gameObject.name, "|")[2] .. ".png",
                            callBack)
                    end





                    gameItem.gameObject:SetActive(true)
                end
            end

            self.gameGrid.repositionNow = true
            self.gameGrid:Reposition()
            self.gameScrollbar.value = 0
            --sort 排序
        else
            print(stringify(data))
        end
    end)
    --获取游戏类型
    require("NetWork.NetHttp").SendGetRequest("/game/game/index/constant", function(ok, data)
        if ok then
            print("游戏类型" .. stringify(data))
        else
            print("获取游戏类型失败" .. stringify(data))
        end
    end)
    self.daili_jinbi_lable = UIUtility.FindContorl("UILabel", "daili_jinbi_lable", t)
    self.wode_yue_lable = UIUtility.FindContorl("UILabel", "wode_yue_lable", t)
    self.wode_jifen_lable = UIUtility.FindContorl("UILabel", "wode_jifen_lable", t)
    self.wode_userName_lable = UIUtility.FindContorl("UILabel", "wode_userName_lable", t)
    self.wode_userid_lable = UIUtility.FindContorl("UILabel", "wode_userid_lable", t)
    --给所有游戏下分 /game/api/downAllScore     /game/api/downScore
    require("NetWork.NetHttp").SendGetRequest("/game/api/downAllScore", function(ok, data)
        if ok then
            --获取用户信息
            self:UpdateUserInfo()
        else
            print(stringify(data))
        end
    end)

    for i = 1, #self.DowntoggleArr do
        function toggle_shouyeChange()
            if self.DowntoggleArr[i].value then
                self.isShow = i == 1
                for j = 1, #self.allGamePanel do
                    self.allGamePanel[j].gameObject:SetActive(i == j)
                end
            end
        end

        self.DowntoggleArr[i].onChange:Clear()
        self.DowntoggleArr[i].onChange:Add(UIHelper.CreateEventDelegate(toggle_shouyeChange,
            self.DowntoggleArr[i].gameObject))
    end
    self.DowntoggleArr[1].value = true

    --商城

    UIHelper.BindUIEvnet("Click", function()
        local win = UIWinMgr:OpenWindow("ZhuanRuZhuanChuWin")
        win:SetTag(2)
    end, UIUtility.GetChildTransform("shop_baoxian_zhuanru_btn", t, true).gameObject)

    UIHelper.BindUIEvnet("Click", function()
        local win = UIWinMgr:OpenWindow("ZhuanRuZhuanChuWin")
        win:SetTag(1)
    end, UIUtility.GetChildTransform("shop_baoxian_zhuanchu_btn", t, true).gameObject)

    self.hall_kefu_btn = UIUtility.GetChildTransform("hall_kefu_btn", t, true)
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenWindow("KefuWin", 1)
    end, self.hall_kefu_btn.gameObject)

    self.hall_gengduo_btn = UIUtility.GetChildTransform("hall_gengduo_btn", t, true)
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenTextNotice("敬请期待")
    end, self.hall_gengduo_btn.gameObject)

    self.hall_xiazai_btn = UIUtility.GetChildTransform("hall_xiazai_btn", t, true)
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenTextNotice("敬请期待")
    end, self.hall_xiazai_btn.gameObject)

    self.wode_kefu_btn = UIUtility.GetChildTransform("wode_kefu_btn", t, true)
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenWindow("KefuWin", 1)
    end, self.wode_kefu_btn.gameObject)



    self.shop_chongzhi_toggle = UIUtility.FindContorl("UIToggle", "shop_chongzhi_toggle", t)
    self.shop_tixian_toggle = UIUtility.FindContorl("UIToggle", "shop_tixian_toggle", t)
    self.shop_baoxiangui_toggle = UIUtility.FindContorl("UIToggle", "shop_baoxiangui_toggle", t)
    self.shop_jilu_toggle = UIUtility.FindContorl("UIToggle", "shop_jilu_toggle", t)
    self.shopAllUpToggleArr = { self.shop_chongzhi_toggle, self.shop_tixian_toggle, self.shop_baoxiangui_toggle, self
        .shop_jilu_toggle }

    self.shop_chongzhi_panel = UIUtility.GetChildTransform("shop_chongzhi_panel", t, true)
    self.shop_tixian_panel = UIUtility.GetChildTransform("shop_tixian_panel", t, true)
    self.shop_baoxiangui_panel = UIUtility.GetChildTransform("shop_baoxiangui_panel", t, true)
    self.shop_cqkjl_panel = UIUtility.GetChildTransform("shop_cqkjl_panel", t, true)
    self.shopAllUpPanel = { self.shop_chongzhi_panel, self.shop_tixian_panel, self.shop_baoxiangui_panel, self
        .shop_cqkjl_panel }
    for i = 1, #self.shopAllUpToggleArr do
        function shopAllUpToggleChange()
            if self.shopAllUpToggleArr[i].value then
                for j = 1, #self.shopAllUpPanel do
                    self.shopAllUpPanel[j].gameObject:SetActive(i == j)
                end
            end
        end

        self.shopAllUpToggleArr[i].onChange:Clear()
        self.shopAllUpToggleArr[i].onChange:Add(UIHelper.CreateEventDelegate(shopAllUpToggleChange,
            self.shopAllUpToggleArr[i].gameObject))
    end
    self.shopAllUpToggleArr[1].value = true




    --金额选项
    self.shop_xiane_price_grid = UIUtility.GetChildTransform("shop_xiane_price_grid", t, true)
    self.allPayMethodLableGame = {}
    for i = 0, self.shop_xiane_price_grid.transform.childCount - 1 do
        self.allPayMethodLableGame[i + 1] = self.shop_xiane_price_grid.transform:GetChild(i):GetComponent("UIToggle")
    end

    self.shop_cur_xiane_input = UIUtility.FindContorl("UIInput", "shop_cur_xiane_input", t)
    self.allPayMethodLableGame_index = 1
    self.allPayMethodLableGame_index_lable = ""
    self.shop_cur_xiane_input.onChange:Clear()
    self.shop_cur_xiane_input.onChange:Add(UIHelper.CreateEventDelegate(function()
        -- for i = 1, #self.allPayMethodLableGame do
        --     self.allPayMethodLableGame[2].value = true
        -- end
        self.allPayMethodLableGame_index_lable = self.shop_cur_xiane_input.value
    end, self.shop_cur_xiane_input.gameObject))

    --更新金额选项点击
    for i = 1, #self.allPayMethodLableGame do
        self.allPayMethodLableGame[i].onChange:Clear()
        self.allPayMethodLableGame[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.allPayMethodLableGame[i].value then
                self.shop_cur_xiane_input.value = UIUtility.FindContorl("UILabel", "Label1",
                    self.allPayMethodLableGame[i].transform).text
                self.allPayMethodLableGame_index = i
                self.allPayMethodLableGame_index_lable = self.shop_cur_xiane_input.value
            end
        end, self.allPayMethodLableGame[i].gameObject))
    end
    -- self.allPayMethodLableGame[1].value=true

    self.shop_xiane_leble = UIUtility.FindContorl("UILabel", "shop_xiane_leble", t)

    self.shop_weixin_toggle_item = UIUtility.GetChildTransform("shop_weixin_toggle_item", t, true)
    self.shop_weixin_toggle_value_item = UIUtility.GetChildTransform("shop_weixin_toggle_value_item", t, true)
    self.shop_chongzhi_zhifu_grid = UIUtility.FindContorl("UIGrid", "shop_chongzhi_zhifu_grid", t)
    self.shop_chongzhi_zhifu_value_grid = UIUtility.FindContorl("UIGrid", "shop_chongzhi_zhifu_value_grid", t)
    self.shop_chongzhi_zhifu_Scrollbar = UIUtility.FindContorl("UIScrollBar", "shop_chongzhi_zhifu_Scrollbar", t)

    self.shop_chongzhi_value_Scrollbar = UIUtility.FindContorl("UIScrollBar", "shop_chongzhi_value_Scrollbar", t)
    self.all_shop_zhifu_data = {}
    self.all_shop_zhifu_data_index = 1

    self.shop_chongzhi_zhifu_type_all = {}
    for i = 1, self.shop_chongzhi_zhifu_grid.transform.childCount do
        self.shop_chongzhi_zhifu_type_all[i] = self.shop_chongzhi_zhifu_grid.transform:GetChild(i - 1):GetComponent(
            "UIToggle")
        self.shop_chongzhi_zhifu_type_all[i].onChange:Clear()
        self.shop_chongzhi_zhifu_type_all[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.shop_chongzhi_zhifu_type_all[i].value then
                --i为类型
                local isShowToggle = false
                local tempToggle
                local isFirst = true
                for j = 1, self.shop_chongzhi_zhifu_value_grid.transform.childCount do
                    local gameItem = self.shop_chongzhi_zhifu_value_grid.transform:GetChild(j - 1)
                    if atools:Split(gameItem.gameObject.name, "_")[1] == tostring(i) then
                        gameItem.gameObject:SetActive(true)
                        if isFirst then
                            isFirst = false
                            tempToggle = gameItem.transform:GetComponent("UIToggle")
                        end
                    else
                        gameItem.gameObject:SetActive(false)
                    end
                end
                --  if  isShowToggle ==false then
                -- tempToggle.value=true
                tempToggle:Set(true, true)
                local indexCur = tonumber(atools:Split(tempToggle.gameObject.name, "_")[2])


                self.all_shop_zhifu_data_index = indexCur
                local minMax = atools:Split(self.all_shop_zhifu_data[indexCur].minMax, ",")
                self.shop_xiane_leble.text = "限额" .. minMax[1] .. "-" .. minMax[2]
                --更新金额选项
                local amountPrice = atools:Split(self.all_shop_zhifu_data[indexCur].amountPrice, ",")
                for j = 1, #amountPrice do
                    UIUtility.FindContorl("UILabel", "Label1", self.allPayMethodLableGame[j].transform).text =
                        amountPrice[j]
                    UIUtility.FindContorl("UILabel", "Label2", self.allPayMethodLableGame[j].transform).text =
                        amountPrice[j]
                end

                for j = 1, #self.allPayMethodLableGame do
                    self.allPayMethodLableGame[j].transform.gameObject:SetActive(j <= #amountPrice)
                end

                --默认到第一个
                self.allPayMethodLableGame[1].value = true
                self.shop_cur_xiane_input.value = UIUtility.FindContorl("UILabel", "Label1",
                    self.allPayMethodLableGame[1].transform).text
                self.allPayMethodLableGame_index = i
                self.allPayMethodLableGame_index_lable = self.shop_cur_xiane_input.value


                -- end
                self.shop_chongzhi_zhifu_value_grid.repositionNow = true
                self.shop_chongzhi_zhifu_value_grid:Reposition()
                self.shop_chongzhi_value_Scrollbar.value = 0
            end
        end, self.shop_chongzhi_zhifu_type_all[i].gameObject))
    end






    --获取支付方式
    require("NetWork.NetHttp").SendGetRequest("/byr/pay/method/list/enabled", function(ok, data)
        if ok then
            print("获取支付方式" .. stringify(data))
            -- ["state"] = 1,
            -- ["payPlatform"] = 2,
            -- ["amountPrice"] = "100",
            -- ["id"] = 13,
            -- ["minMax"] = "100,100",
            -- ["payMethodIndex"] = "8001",
            -- ["name"] = "微信测试支付渠道",
            -- ["payServiceId"] = 2,
            --获取用户信息

            self.all_shop_zhifu_data = data.data
            for i = 1, #data.data do
                --没有一个就加一个
                local gameItem = GameObject.Instantiate(self.shop_weixin_toggle_value_item)

                gameItem:GetComponent("UIToggle").onChange:Clear()
                gameItem:GetComponent("UIToggle").onChange:Add(UIHelper.CreateEventDelegate(function()
                    if gameItem:GetComponent("UIToggle").value then
                        self.all_shop_zhifu_data_index = i
                        local minMax = atools:Split(data.data[i].minMax, ",")
                        self.shop_xiane_leble.text = "限额" .. minMax[1] .. "-" .. minMax[2]
                        --更新金额选项
                        local amountPrice = atools:Split(data.data[i].amountPrice, ",")
                        for j = 1, #amountPrice do
                            UIUtility.FindContorl("UILabel", "Label1", self.allPayMethodLableGame[j].transform).text =
                                amountPrice[j]
                            UIUtility.FindContorl("UILabel", "Label2", self.allPayMethodLableGame[j].transform).text =
                                amountPrice[j]
                        end

                        for j = 1, #self.allPayMethodLableGame do
                            self.allPayMethodLableGame[j].transform.gameObject:SetActive(j <= #amountPrice)
                        end

                        --默认到第一个
                        self.allPayMethodLableGame[1].value = true
                        self.shop_cur_xiane_input.value = UIUtility.FindContorl("UILabel", "Label1",
                            self.allPayMethodLableGame[1].transform).text
                        self.allPayMethodLableGame_index = i
                        self.allPayMethodLableGame_index_lable = self.shop_cur_xiane_input.value
                    end
                end, gameItem.gameObject))

                gameItem.transform.parent = self.shop_chongzhi_zhifu_value_grid.transform
                gameItem.transform.localScale = Vector3.one
                gameItem.transform.localPosition = Vector3.zero
                gameItem.transform.localEulerAngles = Vector3.zero
                gameItem.gameObject:SetActive(true)
                gameItem.gameObject.name = data.data[i].payPlatform .. "_" .. i
                if i == 1 then
                    gameItem:GetComponent("UIToggle").value = true
                end

                -- local itemicon = UIUtility.FindContorl("UISprite", "icon", gameItem.transform)
                -- itemicon.spriteName = "shop_pay" .. data.data[i].payPlatform
                -- itemicon.MakePixelPerfect(itemicon)
                UIUtility.FindContorl("UILabel", "lable", gameItem.transform).text = data.data[i]
                    .name
            end

            self.shop_chongzhi_zhifu_value_grid.repositionNow = true
            self.shop_chongzhi_zhifu_value_grid:Reposition()
            self.shop_chongzhi_zhifu_type_all[1].value = true
            -- self.shop_chongzhi_zhifu_Scrollbar.value=0
        else
            print(stringify(data))
        end
    end)

    --充值确认按钮绑定
    self.shop_cz_qr_btn = UIUtility.FindContorl("UIButton", "shop_cz_qr_btn", t)
    UIHelper.BindUIEvnet("Click", function()
        local ConfigModule = require("Module.ConfigModule").ConfigModule
        --类型固定位1  1为普通充值
        local registerJson = string.format('{"payType": %s, "payMethodId": %s,"amount": %s}', 1,
            self.all_shop_zhifu_data[self.all_shop_zhifu_data_index].id,
            (tonumber(self.allPayMethodLableGame_index_lable)) * 100)


        NetHelper.PostRequest_token(ConfigModule.SessionUrl .. "/byr/payment/createPay", registerJson,
            function(strdata)
                local jsondata = json.decode(tolua.tolstring(strdata))
                if jsondata.code == 200 then
                    --打开支付页面
                    --关闭游戏音效
                    -- local SoundModule = require("Module.SoundModule").SoundModule
                    -- SoundModule:SetAllBgVolume(0)

                    local WebViewWindow = UIWinMgr:OpenWindow("WebViewKefuWindow")
                    WebViewWindow.gamePlatformId = 1
                    --   print("登录成功" .. __data.data.loginUrl)
                    WebViewWindow:SetUrl(jsondata.data)
                    WebViewWindow:SetAudioMuted(false)
                else
                    UIWinMgr:OpenTextNotice(jsondata.msg)
                    Debug.LogErrorEx("jsondata.target~~~~~~~~~~~~~~~~~~1111111111111111111~~~" .. stringify(strdata))
                end
            end, require("NetWork.NetHttp").NetHttp.token)
    end, self.shop_cz_qr_btn.gameObject)


    --提现
    require("NetWork.NetHttp").SendGetRequest("/byr/payment/withdraw/info", function(ok, data)
        if ok then
            print("获取提现信息" .. stringify(data))
        else
            print(stringify(data))
        end
    end)


    self.all_tixian_type_toggle = {}
    self.all_tixian_type_toggle_index = 1
    self.shop_cur_tixian_xiane_input_lable = ""


    self.shop_tixian_weixin_toggle1 = UIUtility.FindContorl("UIToggle", "shop_tixian_weixin_toggle1", t)
    self.shop_tixian_weixin_toggle1.value = true
    self.shop_tixian_weixin_toggle2 = UIUtility.FindContorl("UIToggle", "shop_tixian_weixin_toggle2", t)

    self.shop_tixian_weixin_toggle3 = UIUtility.FindContorl("UIToggle", "shop_tixian_weixin_toggle3", t)
    self.all_tixian_type_toggle = { self.shop_tixian_weixin_toggle1, self.shop_tixian_weixin_toggle2, self
        .shop_tixian_weixin_toggle3 }

    self.all_shop_tixian_price_grid = {}
    self.shop_tixian_price_grid = UIUtility.FindContorl("UIGrid", "shop_tixian_price_grid", t)
    for i = 1, self.shop_tixian_price_grid.transform.childCount do
        self.all_shop_tixian_price_grid[i] = self.shop_tixian_price_grid.transform:GetChild(i - 1):GetComponent(
            "UIToggle")
    end

    self.shop_cur_tixian_xiane_input = UIUtility.FindContorl("UIInput", "shop_cur_tixian_xiane_input", t)
    self.shop_cur_tixian_xiane_input.onChange:Clear()
    self.shop_cur_tixian_xiane_input.onChange:Add(UIHelper.CreateEventDelegate(function()
        self.shop_cur_tixian_xiane_input_lable = self.shop_cur_tixian_xiane_input.value
    end, self.shop_cur_tixian_xiane_input.gameObject))

    for i = 1, #self.all_shop_tixian_price_grid do
        self.all_shop_tixian_price_grid[i].onChange:Clear()
        self.all_shop_tixian_price_grid[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.all_shop_tixian_price_grid[i].value then
                self.shop_cur_tixian_xiane_input.value = UIUtility.FindContorl("UILabel", "Label1",
                    self.all_shop_tixian_price_grid[i].transform).text
            end
        end, self.all_shop_tixian_price_grid[i].gameObject))
    end
    self.all_shop_tixian_price_grid[2].value = true

    self.xiaoxi_xitongxiaoxi_toggle = UIUtility.FindContorl("UIToggle", "xiaoxi_xitongxiaoxi_toggle", t)
    self.xiaoxi_xitongxiaoxi_toggle.value = true

    self.shop_tixian_add_label = UIUtility.FindContorl("UILabel", "shop_tixian_add_label", t)
    self.shop_tixian_qtj_btn = UIUtility.GetChildTransform("shop_tixian_qtj_btn", t, true)
    self.all_shop_tixian_add_label = { "请添加银行卡地址", "请添加支付宝地址", "请添加USDT地址" }
    for i = 1, #self.all_tixian_type_toggle do
        self.all_tixian_type_toggle[i].onChange:Clear()
        self.all_tixian_type_toggle[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.all_tixian_type_toggle[i].value then
                self.shop_tixian_add_label.text = self.all_shop_tixian_add_label[i]
                self.all_tixian_type_toggle_index = i
            end
        end, self.all_tixian_type_toggle[i].gameObject))
    end
    --请添加提币地址
    UIHelper.BindUIEvnet("Click", function()
        if self.shop_tixian_add_label.text == self.all_shop_tixian_add_label[1] then
            --获取用户信息，如果没设置二级密码，优先设置二级密码
            UIWinMgr:OpenWindow("AddBankCardWin", 1)
        elseif self.shop_tixian_add_label.text == self.all_shop_tixian_add_label[2] then
            UIWinMgr:OpenWindow("AddZFBWin", 1)
        elseif self.shop_tixian_add_label.text == self.all_shop_tixian_add_label[3] then
            UIWinMgr:OpenWindow("AddUSDTCardWin", 1)
        end
        if self.user_data.havaSecondPassword == 0 then
            UIWinMgr:OpenWindow("SetTiXianPasswordWin", 1)
        end
    end, self.shop_tixian_qtj_btn.gameObject)

    self.shop_tixian_queren_btn = UIUtility.GetChildTransform("shop_tixian_queren_btn", t, true)
    self.user_data_secondPassword = ""
    self.user_data_withdrawId = 0
    UIHelper.BindUIEvnet("Click", function()
        --提现  all_tixian_type_toggle_index  为类型
        self:Pay_btn()
    end, self.shop_tixian_queren_btn.gameObject)

    self.user_data = {}
    self.user_data_bankinfo = {}
    self.user_data_zfbinfo = {}
    self.user_data_usdtinfo = {}
    self.daili_wddl_tjid_lable = UIUtility.FindContorl("UILabel", "daili_wddl_tjid_lable", t)
    self.daili_wddl_zsid_lable = UIUtility.FindContorl("UILabel", "daili_wddl_zsid_lable", t)
    self.wode_vip_label = UIUtility.FindContorl("UILabel", "wode_vip_label", t)
    self.shouye_vip_label = UIUtility.FindContorl("UILabel", "shouye_vip_label", t)
    --获取用户信息
    require("NetWork.NetHttp").SendGetRequest("/byr/user/profile", function(ok, data)
        if ok then
            -- ["phone"] = userdata<userdata: NULL>,
            -- ["status"] = 1,
            -- ["nickName"] = userdata<userdata: NULL>,
            -- ["avatar"] = userdata<userdata: NULL>,
            -- ["agentCode"] = "9RJ4Y3VA",
            -- ["parentAgentCode"] = userdata<userdata: NULL>,
            -- ["email"] = userdata<userdata: NULL>,
            -- ["username"] = "cy1996",
            -- ["userId"] = 102355,
            -- ["havaSecondPassword"] = 0,
            self.user_data = data.data
            --更新推荐码
            self.daili_wddl_tjid_lable.text = data.data.agentCode
            self.daili_wddl_zsid_lable.text = data.data.agentCode
            self.userName_text.text = data.data.username
            self.wode_userName_lable.text = data.data.username
            --更新VIP等级
            self.wode_vip_label.text = data.data.vipLevel
            self.shouye_vip_label.text = data.data.vipLevel

            print("获取用户信息" .. stringify(data))
        else
            print(stringify(data))
        end
    end)

    --保险柜
    self.shop_baoxiangui_policyBalance_lable = UIUtility.FindContorl("UILabel", "shop_baoxiangui_policyBalance_lable", t)

    self.shop_baoxian_shouyi_lable = UIUtility.FindContorl("UILabel", "shop_baoxian_shouyi_lable", t)

    self.shop_baoxiangui_up_toggle = {
        UIUtility.FindContorl("UIToggle", "shop_baoxiangui_symx_toggle", t),
        UIUtility.FindContorl("UIToggle", "shop_baoxiangui_bxgmx_toggle", t),
        UIUtility.FindContorl("UIToggle", "shop_baoxiangui_lxgz_toggle", t)
    }

    self.shop_baoxiangui_panel_panel = {
        UIUtility.GetChildTransform("shop_baoxiangui_symx_panel", t, true),
        UIUtility.GetChildTransform("shop_baoxiangui_bxgmx_panel", t, true),
        UIUtility.GetChildTransform("shop_baoxiangui_lxgz_panel", t, true),
    }

    self.shop_baoxiangui_grid_Item2 = UIUtility.GetChildTransform("shop_baoxiangui_grid_Item2", t, true)

    self.shop_baoxiangui_jlmx_grid2 = UIUtility.FindContorl("UIGrid", "shop_baoxiangui_jlmx_grid2", t)

    for i = 1, #self.shop_baoxiangui_up_toggle do
        self.shop_baoxiangui_up_toggle[i].onChange:Clear()
        self.shop_baoxiangui_up_toggle[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.shop_baoxiangui_up_toggle[i].value then
                self.shop_baoxiangui_panel_panel[i].gameObject:SetActive(true)
                if i == 2 then
                    require("NetWork.NetHttp").SendGetRequest("/byr/wallet/transfer/record", function(ok, data)
                        if ok then
                            for j = 1, self.shop_baoxiangui_jlmx_grid2.transform.childCount do
                                if j ~= 1 then
                                    GameObject.Destroy(self.shop_baoxiangui_jlmx_grid2.transform:GetChild(j - 1)
                                        .gameObject)
                                end
                            end
                            print("获取保险转入转出" .. stringify(data))
                            for i = 1, #data.data do
                                -- ["policyBalance"] = 48460,
                                -- ["updateTime"] = "2025-05-30 21:03:00",
                                -- ["createTime"] = "2025-05-30 21:03:00",
                                -- ["id"] = 95,
                                -- ["rate"] = 0.0002,
                                -- ["userId"] = 1,
                                -- ["incomeAmount"] = 10,
                                local item = GameObject.Instantiate(self.shop_baoxiangui_grid_Item2)
                                item.gameObject:SetActive(true)
                                item.transform.parent = self.shop_baoxiangui_jlmx_grid2.transform
                                item.transform.localScale = Vector3.one
                                item.transform.localPosition = Vector3.zero
                                item.transform.localEulerAngles = Vector3.zero

                                UIUtility.FindContorl("UILabel", "time_lable", item).text = data.data[i]
                                    .createTime
                                UIUtility.FindContorl("UILabel", "num_lable", item).text = data.data[i]
                                    .amount / 100
                                UIUtility.FindContorl("UILabel", "type_lable", item).text = data.data[i]
                                    .afterPolicyBalance / 100
                                UIUtility.GetChildTransform("bg_sprite", item, true).gameObject:SetActive(i % 2 ~= 0)
                            end
                            self.shop_baoxiangui_jlmx_grid2.repositionNow = true
                            self.shop_baoxiangui_jlmx_grid2:Reposition()
                        else
                            UIWinMgr:OpenTextNotice(data.msg)
                        end
                    end)
                end
            else
                self.shop_baoxiangui_panel_panel[i].gameObject:SetActive(false)
            end
        end, self.shop_baoxiangui_up_toggle[i].gameObject))
    end
    self.shop_baoxiangui_up_toggle[1].value = true





    self.shop_baoxiangui_grid_Item = UIUtility.GetChildTransform("shop_baoxiangui_grid_Item", t, true)

    self.shop_baoxiangui_jlmx_grid = UIUtility.FindContorl("UIGrid", "shop_baoxiangui_jlmx_grid", t)
    --获取保险盈利记录
    require("NetWork.NetHttp").SendGetRequest("/byr/policy/income/page", function(ok, data)
        if ok then
            print("获取保险盈利记录" .. stringify(data))
            for i = 1, #data.data.records do
                -- ["policyBalance"] = 48460,
                -- ["updateTime"] = "2025-05-30 21:03:00",
                -- ["createTime"] = "2025-05-30 21:03:00",
                -- ["id"] = 95,
                -- ["rate"] = 0.0002,
                -- ["userId"] = 1,
                -- ["incomeAmount"] = 10,
                local item = GameObject.Instantiate(self.shop_baoxiangui_grid_Item)
                item.gameObject:SetActive(true)
                item.transform.parent = self.shop_baoxiangui_jlmx_grid.transform
                item.transform.localScale = Vector3.one
                item.transform.localPosition = Vector3.zero
                item.transform.localEulerAngles = Vector3.zero

                UIUtility.FindContorl("UILabel", "time_lable", item).text = data.data.records[i].updateTime
                UIUtility.FindContorl("UILabel", "num_lable", item).text = data.data.records[i].incomeAmount / 100
                UIUtility.GetChildTransform("bg_sprite", item, true).gameObject:SetActive(i % 2 ~= 0)
            end
            self.shop_baoxiangui_jlmx_grid.repositionNow = true
            self.shop_baoxiangui_jlmx_grid:Reposition()
        else
            print(stringify(data))
        end
    end)
    self.shop_cqkjl_qk_name_const = {
        [1] = "支付宝",
        [2] = "微信",
        [3] = "银行卡",
        [4] = "USDT",
        [5] = "淘宝",
        [6] = "云闪付",
        [7] = "数字货币",
        [8] = "QQ"
    }

    --存取款记录
    self.shop_cqkjl_ck_state_const = {
        [1] = "待支付",
        [2] = "支付成功",
        [3] = "支付取消",
        [4] = "支付失败",
    }

    self.shop_cqkjl_ck_state_color = {
        [1] = Color(255 / 255, 170 / 255, 0 / 255),
        [2] = Color(255 / 255, 0 / 255, 0 / 255),
        [3] = Color(255 / 255, 200 / 255, 0 / 255),
        [4] = Color(0 / 255, 255 / 255, 0 / 255),

    }

    self.shop_cqkjl_ck_toggle = UIUtility.FindContorl("UIToggle", "shop_cqkjl_ck_toggle", t)
    self.shop_cqkjl_ck_panel = UIUtility.GetChildTransform("shop_cqkjl_ck_panel", t, true)
    self.shop_cqkjl_ck_grid = UIUtility.FindContorl("UIGrid", "shop_cqkjl_ck_grid", t)
    self.shop_cqkjl_ck_grid_item = UIUtility.GetChildTransform("shop_cqkjl_ck_grid_item", t, true)
    self.shop_cqkjl_ck_toggle.onChange:Clear()
    self.shop_cqkjl_ck_toggle.onChange:Add(UIHelper.CreateEventDelegate(function()
        if self.shop_cqkjl_ck_toggle.value then
            self.shop_cqkjl_ck_panel.gameObject:SetActive(true)
            --请求存取款记录
            require("NetWork.NetHttp").SendGetRequest("/byr/payment/pay/list?pageNum=1&pageSize=30", function(ok, data)
                if ok then
                    print("获取存款记录" .. stringify(data))
                    --删除所有子节点
                    for i = 1, self.shop_cqkjl_ck_grid.transform.childCount do
                        if i ~= 1 then
                            GameObject.Destroy(self.shop_cqkjl_ck_grid.transform:GetChild(i - 1).gameObject)
                        end
                    end
                    for i = 1, #data.data.list do
                        local item = GameObject.Instantiate(self.shop_cqkjl_ck_grid_item)
                        item.gameObject:SetActive(true)
                        item.transform.parent = self.shop_cqkjl_ck_grid.transform
                        item.transform.localScale = Vector3.one
                        item.transform.localPosition = Vector3.zero
                        item.transform.localEulerAngles = Vector3.zero
                        local itemicon = UIUtility.FindContorl("UISprite", "pay_icon", item)
                        itemicon.spriteName = "shop_pay" ..
                            (data.data.list[i].payPlatform == nil and "0" or data.data.list[i].payPlatform)
                        itemicon.MakePixelPerfect(itemicon)
                        UIUtility.FindContorl("UILabel", "pay_time_lable", item).text = data.data.list[i].createTime
                        UIUtility.FindContorl("UILabel", "pay_jine_lable", item).text = data.data.list[i].totalAmount /
                            100
                        UIUtility.FindContorl("UILabel", "pay_name_lable", item).text = self.shop_cqkjl_qk_name_const
                            [data.data.list[i].payPlatform]
                        UIUtility.FindContorl("UILabel", "pay_status_lable", item).text = self.shop_cqkjl_ck_state_const
                            [data.data.list[i].payState]
                        UIUtility.FindContorl("UILabel", "pay_status_lable", item).color = self
                            .shop_cqkjl_ck_state_color
                            [data.data.list[i].payState]
                    end
                    self.shop_cqkjl_ck_grid.repositionNow = true
                    self.shop_cqkjl_ck_grid:Reposition()
                end
            end)
        else
            self.shop_cqkjl_ck_panel.gameObject:SetActive(false)
        end
    end, self.shop_cqkjl_ck_toggle.gameObject))

    self.shop_cqkjl_ck_toggle.value = true

    self.shop_cqkjl_qk_toggle = UIUtility.FindContorl("UIToggle", "shop_cqkjl_qk_toggle", t)
    self.shop_cqkjl_qk_panel = UIUtility.GetChildTransform("shop_cqkjl_qk_panel", t, true)
    self.shop_cqkjl_qk_grid = UIUtility.FindContorl("UIGrid", "shop_cqkjl_qk_grid", t)
    self.shop_cqkjl_qk_grid_item = UIUtility.GetChildTransform("shop_cqkjl_qk_grid_item", t, true)
    self.shop_cqkjl_qk_toggle.onChange:Clear()


    self.shop_cqkjl_qk_state_const = {
        [1] = "待提现",
        [2] = "提现中",
        [3] = "提现成功",
        [4] = "提现拒绝",
        [5] = "提现失败",
    }

    self.shop_cqkjl_qk_state_color = {
        [1] = Color(48 / 255, 48 / 255, 48 / 255),
        [2] = Color(48 / 255, 48 / 255, 48 / 255),
        [3] = Color(35 / 255, 183 / 255, 20 / 255),
        [4] = Color(255 / 255, 200 / 255, 0 / 255),
        [5] = Color(205 / 255, 91 / 255, 70 / 255)
    }

    self.shop_cqkjl_qk_cion_const = {
        [1] = "3",
        [2] = "1",
        [3] = "4"
    }

    self.shop_cqkjl_qk_toggle.onChange:Add(UIHelper.CreateEventDelegate(function()
        if self.shop_cqkjl_qk_toggle.value then
            self.shop_cqkjl_qk_panel.gameObject:SetActive(true)
            --请求存取款记录
            require("NetWork.NetHttp").SendGetRequest("/byr/payment/repay/list?pageNum=1&pageSize=30", function(ok, data)
                if ok then
                    print("获取取款记录" .. stringify(data))
                    --删除所有子节点
                    for i = 1, self.shop_cqkjl_qk_grid.transform.childCount do
                        if i ~= 1 then
                            GameObject.Destroy(self.shop_cqkjl_qk_grid.transform:GetChild(i - 1).gameObject)
                        end
                    end
                    for i = 1, #data.data.list do
                        local item = GameObject.Instantiate(self.shop_cqkjl_qk_grid_item)
                        item.gameObject:SetActive(true)
                        item.transform.parent = self.shop_cqkjl_qk_grid.transform
                        item.transform.localScale = Vector3.one
                        item.transform.localPosition = Vector3.zero
                        item.transform.localEulerAngles = Vector3.zero
                        local itemicon = UIUtility.FindContorl("UISprite", "pay_icon", item)
                        itemicon.spriteName = "shop_pay" .. self.shop_cqkjl_qk_cion_const
                            [data.data.list[i].withdrawType]
                        itemicon.MakePixelPerfect(itemicon)
                        UIUtility.FindContorl("UILabel", "pay_time_lable", item).text = data.data.list[i].updateTime
                        UIUtility.FindContorl("UILabel", "pay_jine_lable", item).text = data.data.list[i].amount / 100
                        UIUtility.FindContorl("UILabel", "pay_name_lable", item).text = self.shop_cqkjl_qk_name_const
                            [tonumber(self.shop_cqkjl_qk_cion_const[data.data.list[i].withdrawType])]
                        UIUtility.FindContorl("UILabel", "pay_status_lable", item).text = self.shop_cqkjl_qk_state_const
                            [data.data.list[i].state + 1]
                        UIUtility.FindContorl("UILabel", "pay_status_lable", item).color = self
                            .shop_cqkjl_qk_state_color
                            [data.data.list[i].state + 1]
                    end
                    self.shop_cqkjl_qk_grid.repositionNow = true
                    self.shop_cqkjl_qk_grid:Reposition()
                end
            end)
        else
            self.shop_cqkjl_qk_panel.gameObject:SetActive(false)
        end
    end, self.shop_cqkjl_qk_toggle.gameObject))
    --系统消息 积分消息
    self.xiaoxi_up_toggle_panel = UIUtility.GetChildTransform("xiaoxi_up_toggle_panel", t, true)
    self.xiaoxi_xitong_panel = UIUtility.GetChildTransform("xiaoxi_xitong_panel", t, true)
    self.xiaoxi_jifen_panel = UIUtility.GetChildTransform("xiaoxi_jifen_panel", t, true)
    self.xiaoxi_up_toggle_panel_arr = {}
    self.xiaoxi_panel_arr = { self.xiaoxi_xitong_panel, self.xiaoxi_jifen_panel }
    for i = 1, self.xiaoxi_up_toggle_panel.transform.childCount do
        self.xiaoxi_up_toggle_panel_arr[i] = self.xiaoxi_up_toggle_panel.transform:GetChild(i - 1):GetComponent(
            "UIToggle")
    end
    for i = 1, #self.xiaoxi_up_toggle_panel_arr do
        self.xiaoxi_up_toggle_panel_arr[i].onChange:Clear()
        self.xiaoxi_up_toggle_panel_arr[i].onChange:Add(UIHelper.CreateEventDelegate(function()
            if self.xiaoxi_up_toggle_panel_arr[i].value then
                self.xiaoxi_panel_arr[i].gameObject:SetActive(true)
                if i == 2 then
                    require("NetWork.NetHttp").SendGetRequest("/byr/balance/record/page?pageNum=1&pageSize=30",
                        function(ok, data)
                            if ok then
                                print("获取积分消息" .. stringify(data))
                                local grid = UIUtility.FindContorl("UIGrid", "xiaoxi_grid", self.xiaoxi_jifen_panel)
                                local grid_item = UIUtility.GetChildTransform("xiaoxi_grid_item",
                                    self.xiaoxi_panel_arr[i], true)
                                --删除所有的子节点
                                for i = 1, grid.transform.childCount do
                                    if i ~= 1 then
                                        GameObject.Destroy(grid.transform:GetChild(i - 1).gameObject)
                                    end
                                end
                                for i = 1, #data.data.list do
                                    local item = GameObject.Instantiate(grid_item)
                                    item.gameObject:SetActive(true)
                                    item.transform.parent = grid.transform
                                    item.transform.localScale = Vector3.one
                                    item.transform.localPosition = Vector3.zero
                                    item.transform.localEulerAngles = Vector3.zero
                                    UIUtility.FindContorl("UILabel", "time_lable", item).text = data.data.list[i]
                                        .createTime
                                    UIUtility.FindContorl("UILabel", "msg", item).text = self.xiaoxi_type_const
                                        [data.data.list[i].actionType + 1] ..
                                        ":" ..
                                        (data.data.list[i].amount / 100) ..
                                        "  积分余额:" .. (data.data.list[i].balanceAfter / 100)
                                end
                                grid.repositionNow = true
                                grid:Reposition()
                            end
                        end)
                end
            else
                self.xiaoxi_panel_arr[i].gameObject:SetActive(false)
            end
        end, self.xiaoxi_up_toggle_panel_arr[i].gameObject))
    end
    self.xiaoxi_up_toggle_panel_arr[1].value = true


    self.xiaoxi_type_const = {
        [1] = "充值",
        [2] = "提现",
        [3] = "游戏上分",
        [4] = "游戏下分",
        [5] = "系统礼金赠送",
        [6] = "系统余额充值",
        [7] = "系统扣款",
        [8] = "每日首冲赠送",
        [11] = "撤回游戏上分",
        [12] = "撤回提现",
    }

    --代理

    self.daili_wddl_panel = UIUtility.GetChildTransform("daili_wddl_panel", t, true)
    self.daili_yjcx_panel = UIUtility.GetChildTransform("daili_yjcx_panel", t, true)
    self.daili_fybl_panel = UIUtility.GetChildTransform("daili_fybl_panel", t, true)
    self.daili_wjcx_panel = UIUtility.GetChildTransform("daili_wjcx_panel", t, true)
    self.daili_dljs_panel = UIUtility.GetChildTransform("daili_dljs_panel", t, true)
    self.daili_all_panel = { self.daili_wddl_panel, self.daili_yjcx_panel, self.daili_fybl_panel, self.daili_wjcx_panel,
        self.daili_dljs_panel }

    --可领取佣金
    self.daili_wddl_down_klqyj_lable = UIUtility.FindContorl("UILabel", "daili_wddl_down_klqyj_lable", t)
    --历史总佣金

    --领取按钮
    UIHelper.BindUIEvnet("Click", function()
        if self.balance_data.commissionBalance > 0 then
            local data = string.format(
                '{"fromWalletType":%s,"toWalletType":%s,"amount":%s}',
                2, 1, tonumber(self.balance_data.commissionBalance))

            require("NetWork.NetHttp").SendPostRequest_token("/byr/wallet/transfer",
                function(ok, data)
                    if ok then
                        print("请求转账:" .. stringify(data))
                        UIWinMgr:OpenTextNotice("领取成功")
                        self:UpdateUserInfo()
                    else
                        print("请求转账失败:" .. stringify(data))
                        UIWinMgr:OpenTextNotice(data.msg)
                    end
                end,
                data
            )
        else
            UIWinMgr:OpenTextNotice("可领取佣金为0")
        end
    end, UIUtility.GetChildTransform("daili_wddl_down_ljlq_btn", t, true).gameObject)


    self.daili_up = UIUtility.GetChildTransform("daili_up", t, true)
    self.allDailiUpToggle = {}
    for i = 1, self.daili_up.transform.childCount do
        self.allDailiUpToggle[i] = UIUtility.FindContorl("UIToggle", "daili_wddl_toggle" .. i, self.daili_up.transform)
    end
    for i = 1, #self.allDailiUpToggle do
        self.allDailiUpToggle[i].onChange:Clear()
        self.allDailiUpToggle[i].onChange:Add(UIHelper.CreateEventDelegate(function()
                if self.allDailiUpToggle[i].value then
                    for j = 1, #self.daili_all_panel do
                        self.daili_all_panel[j].gameObject:SetActive(i == j)
                    end
                end
            end,
            self.allDailiUpToggle[i].gameObject))
    end
    self.allDailiUpToggle[1].value = true

    self.daili_wddl_jrzyj_lable = UIUtility.FindContorl("UILabel", "daili_wddl_jrzyj_lable", t)
    self.daili_wddl_jrdlyj_lable = UIUtility.FindContorl("UILabel", "daili_wddl_jrdlyj_lable", t)
    self.daili_wddl_zrxz_lable = UIUtility.FindContorl("UILabel", "daili_wddl_zrxz_lable", t)
    self.daili_wddl_wdtd_lable = UIUtility.FindContorl("UILabel", "daili_wddl_wdtd_lable", t)
    self.daili_wddl_zsrs_lable = UIUtility.FindContorl("UILabel", "daili_wddl_zsrs_lable", t)
    self.daili_wddl_byxz_lable = UIUtility.FindContorl("UILabel", "daili_wddl_byxz_lable", t)
    self.daili_wddl_zryj_lable = UIUtility.FindContorl("UILabel", "daili_wddl_zryj_lable", t)
    self.daili_wddl_down_lszyj_lable = UIUtility.FindContorl("UILabel", "daili_wddl_down_lszyj_lable", t)
    self.daili_wddl_wjzs_lable = UIUtility.FindContorl("UILabel", "daili_wddl_wjzs_lable", t)
    self.daili_wddl_jrxz_lable = UIUtility.FindContorl("UILabel", "daili_wddl_jrxz_lable", t)
    --获取代理信息
    require("NetWork.NetHttp").SendGetRequest("/byr/user/statistics/info", function(ok, data)
        if ok then
            print("获取代理信息" .. stringify(data))
            self.daili_wddl_jrzyj_lable.text = data.data.todayOwnCommission / 100
            self.daili_wddl_jrdlyj_lable.text = data.data.todayAgentCommission / 100
            self.daili_wddl_zrxz_lable.text = data.data.yesterdayNewPeople
            --我的团队人数
            self.daili_wddl_wdtd_lable.text = data.data.myTeamPeopleCount
            self.daili_wddl_wjzs_lable.text = data.data.myTeamPeopleCount

            self.daili_wddl_zsrs_lable.text = data.data.sonNewPeople

            self.daili_wddl_byxz_lable.text = 0 --data.data.mothNewPeople



            self.daili_wddl_zryj_lable.text = data.data.yesterdayOwnCommission / 100
            self.daili_wddl_down_lszyj_lable.text = data.data.historyCommission / 100

            --总收益
            self.shop_baoxian_shouyi_lable.text = data.data.totalReward / 100
        else
            print("获取代理信息失败" .. stringify(data))
        end
    end)
    self.daili_wddl_down_fuzhi_btn = UIUtility.GetChildTransform("daili_wddl_down_fuzhi_btn", t, true)

    UIHelper.BindUIEvnet("Click", function()
        ToolEx.copyStr(self.daili_wddl_zsid_lable.text)
        UIWinMgr:OpenTextNotice("复制成功")
    end, self.daili_wddl_down_fuzhi_btn.gameObject)

    self.daili_wjcx_grid = UIUtility.FindContorl("UIGrid", "daili_wjcx_grid", t)
    self.daili_wjcx_grid_item = UIUtility.GetChildTransform("daili_wjcx_grid_item", t, true)
    self.daili_wjcx_shuru_input = UIUtility.FindContorl("UIInput", "daili_wjcx_shuru_input", t)
    --重置
    UIHelper.BindUIEvnet("Click", function()
        self.daili_wjcx_shuru_input.value = ""
        --获取玩家代理
        require("NetWork.NetHttp").SendGetRequest("/byr/daily/statistics/down/page?pageNum=1&pageSize=5",
            function(ok, data)
                if ok then
                    print("获取玩家代理信息" .. stringify(data))
                    for i = 1, self.daili_wjcx_grid.transform.childCount do
                        if i ~= 1 then
                            GameObject.Destroy(self.daili_wjcx_grid.transform:GetChild(i - 1).gameObject)
                        end
                    end
                    for i = 1, #data.data.list do
                        local item = GameObject.Instantiate(self.daili_wjcx_grid_item)
                        item.gameObject:SetActive(true)
                        item.transform.parent = self.daili_wjcx_grid.transform
                        item.transform.localScale = Vector3.one
                        item.transform.localPosition = Vector3.zero
                        item.transform.localEulerAngles = Vector3.zero

                        UIUtility.GetChildTransform("bg", item, true).gameObject:SetActive(i % 2 ~= 0)
                        UIUtility.FindContorl("UILabel", "index", item).text = i --data.data.list[i].id
                        UIUtility.FindContorl("UILabel", "name", item).text = data.data.list[i].username == nil and "--" or
                            data.data.list[i].username
                        UIUtility.FindContorl("UILabel", "id", item).text = data.data.list[i].userId
                        UIUtility.FindContorl("UILabel", "num", item).text = (data.data.list[i].todayOwnWater) / 100
                        if data.data.list[i].todayOwnWater >= 0 then
                            UIUtility.FindContorl("UILabel", "num", item).color = Color(35 / 255, 183 / 255, 20 / 255)
                        else
                            UIUtility.FindContorl("UILabel", "num", item).color = Color(205 / 255, 91 / 255, 70 / 255)
                        end
                    end
                    self.daili_wjcx_grid.repositionNow = true
                    self.daili_wjcx_grid:Reposition()
                else
                    print("获取玩家代理信息失败" .. stringify(data))
                end
            end)
    end, UIUtility.GetChildTransform("daili_wjcx_chongzhi_btn", t, true).gameObject)

    UIHelper.BindUIEvnet("Click", function()
        if self.daili_wjcx_shuru_input.value == "" then
            UIWinMgr:OpenTextNotice("请输入用户名")
            return
        end

        require("NetWork.NetHttp").SendGetRequest(
            "/byr/daily/statistics/down/page?pageNum=1&pageSize=5&username=" .. self.daili_wjcx_shuru_input.value,
            function(ok, data)
                if ok then
                    print("获取玩家代理信息" .. stringify(data))
                    for i = 1, self.daili_wjcx_grid.transform.childCount do
                        if i ~= 1 then
                            GameObject.Destroy(self.daili_wjcx_grid.transform:GetChild(i - 1).gameObject)
                        end
                    end
                    for i = 1, #data.data.list do
                        local item = GameObject.Instantiate(self.daili_wjcx_grid_item)
                        item.gameObject:SetActive(true)
                        item.transform.parent = self.daili_wjcx_grid.transform
                        item.transform.localScale = Vector3.one
                        item.transform.localPosition = Vector3.zero
                        item.transform.localEulerAngles = Vector3.zero

                        UIUtility.GetChildTransform("bg", item, true).gameObject:SetActive(i % 2 ~= 0)
                        UIUtility.FindContorl("UILabel", "index", item).text = i --data.data.list[i].id
                        UIUtility.FindContorl("UILabel", "name", item).text = data.data.list[i].username == nil and "--" or
                            data.data.list[i].username
                        UIUtility.FindContorl("UILabel", "id", item).text = data.data.list[i].userId
                        UIUtility.FindContorl("UILabel", "num", item).text = (data.data.list[i].todayOwnWater) / 100
                        if data.data.list[i].todayOwnWater >= 0 then
                            UIUtility.FindContorl("UILabel", "num", item).color = Color(35 / 255, 183 / 255, 20 / 255)
                        else
                            UIUtility.FindContorl("UILabel", "num", item).color = Color(205 / 255, 91 / 255, 70 / 255)
                        end
                    end
                    self.daili_wjcx_grid.repositionNow = true
                    self.daili_wjcx_grid:Reposition()
                end
            end)
    end, UIUtility.GetChildTransform("daili_wjcx_sousuo_input", t, true).gameObject)

    --获取今日用户统计
    require("NetWork.NetHttp").SendGetRequest("/byr/daily/statistics/dateDay", function(ok, data)
        if ok then
            print("获取今日用户统计" .. stringify(data))

            -- self.daili_wddl_jrxz_lable.text = data.data.todayTeamPeople
        end
    end)

    --获取玩家代理
    require("NetWork.NetHttp").SendGetRequest("/byr/daily/statistics/down/page?pageNum=1&pageSize=5", function(ok, data)
        if ok then
            print("获取玩家代理信息" .. stringify(data))
            for i = 1, self.daili_wjcx_grid.transform.childCount do
                if i ~= 1 then
                    GameObject.Destroy(self.daili_wjcx_grid.transform:GetChild(i - 1).gameObject)
                end
            end
            for i = 1, #data.data.list do
                local item = GameObject.Instantiate(self.daili_wjcx_grid_item)
                item.gameObject:SetActive(true)
                item.transform.parent = self.daili_wjcx_grid.transform
                item.transform.localScale = Vector3.one
                item.transform.localPosition = Vector3.zero
                item.transform.localEulerAngles = Vector3.zero

                UIUtility.GetChildTransform("bg", item, true).gameObject:SetActive(i % 2 ~= 0)
                UIUtility.FindContorl("UILabel", "index", item).text = i --data.data.list[i].id
                UIUtility.FindContorl("UILabel", "name", item).text = data.data.list[i].username == nil and "--" or
                    data.data.list[i].username
                UIUtility.FindContorl("UILabel", "id", item).text = data.data.list[i].userId
                UIUtility.FindContorl("UILabel", "num", item).text = (data.data.list[i].todayOwnWater) / 100
                if data.data.list[i].todayOwnWater >= 0 then
                    UIUtility.FindContorl("UILabel", "num", item).color = Color(35 / 255, 183 / 255, 20 / 255)
                else
                    UIUtility.FindContorl("UILabel", "num", item).color = Color(205 / 255, 91 / 255, 70 / 255)
                end
            end
            self.daili_wjcx_grid.repositionNow = true
            self.daili_wjcx_grid:Reposition()
        else
            print("获取玩家代理信息失败" .. stringify(data))
        end
    end)

    --我的
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenTextNotice("开发中")
    end, UIUtility.GetChildTransform("wpde_yhj_btn", t, true).gameObject)
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenWindow("LiuShuiJiLuWin", 1)
    end, UIUtility.GetChildTransform("wode_lsjl_btn", t, true).gameObject)
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenWindow("YiJianFanKuiWin", 1)
    end, UIUtility.GetChildTransform("wode_yjfk_btn", t, true).gameObject)
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenTextNotice("开发中")
    end, UIUtility.GetChildTransform("wode_zhaq_btn", t, true).gameObject)


    self.wode_yinxiao_toggle = UIUtility.FindContorl("UIToggle", "wode_yinxiao_toggle", t)

    self.wode_yinxiao_toggle.onChange:Clear()
    self.wode_yinxiao_toggle.onChange:Add(UIHelper.CreateEventDelegate(function()
        require("Module.SoundModule").SoundModule:SetAllBgVolume(self.wode_yinxiao_toggle.value == true and 0 or 0.2)
        UnityEngine.PlayerPrefs.SetString("SetSound", self.wode_yinxiao_toggle.value == true and "0" or "1")
    end, self.wode_yinxiao_toggle.gameObject))
    local setSound = UnityEngine.PlayerPrefs.GetString("SetSound")
    if setSound == "1" then
        self.wode_yinxiao_toggle.value = false
    else
        self.wode_yinxiao_toggle.value = true
    end

    local VersionTool = require("VersionTool").VersionTool
    self.Version = VersionTool.getVresion()
    self.wode_banben_lable = UIUtility.FindContorl("UILabel", "wode_banben_lable", t)
    self.wode_banben_lable.text = self.Version

    self.curAdvIndex = 1 --当前广告下标
    self.advIsLeft = false
    --广告
    -----广告
    self.guangGaoScrollView = UIUtility.FindContorl("UIScrollView", "adv_panel", t)
    self.guangGaoPanel = UIUtility.FindContorl("UIPanel", "adv_panel", t)
    self.advSlider = UIUtility.FindContorl("UISlider", "AdvSlider", t)
    --广告左右点击
    self.advLeftBtn = UIUtility.GetChildTransform("shouye_leftBtn", t, true)
    self.advRightBtn = UIUtility.GetChildTransform("shouye_rightBtn", t, true)

    self.advArr = {}
    self.advArr[1] = UIUtility.GetChildTransform("gbnnAdv", t, true)
    self.advArr[2] = UIUtility.GetChildTransform("ttzAdv", t, true)
    self.advArr[3] = UIUtility.GetChildTransform("zjhAdv", t, true)

    self.adv_index1 = UIUtility.FindContorl("UISprite", "adv_index1", t)
    self.adv_index2 = UIUtility.FindContorl("UISprite", "adv_index2", t)
    self.adv_index3 = UIUtility.FindContorl("UISprite", "adv_index3", t)

    self.adv_all_arr = { self.adv_index1, self.adv_index2, self.adv_index3 }


    self.gbnnAdv = UIUtility.GetChildTransform("gbnnAdv", t, true)
    self.ttzAdv = UIUtility.GetChildTransform("ttzAdv", t, true)
    self.zjhAdv = UIUtility.GetChildTransform("zjhAdv", t, true)

    --判断当前滑动到第几个
    self.curAdvIndex = math.floor(self.advSlider.value / (1 / (#self.advArr - 1)) + 0.5) + 1
    self.advRightBtn.gameObject:SetActive(self.curAdvIndex ~= #self.advArr)
    self.advLeftBtn.gameObject:SetActive(self.curAdvIndex ~= 1)
    function advLeftOnClick()
        self.advRightBtn.gameObject:SetActive(true)
        self.advLeftBtn.gameObject:SetActive(self.curAdvIndex ~= 2)
        if self.curAdvIndex - 1 > 0 then
            self.curAdvIndex = self.curAdvIndex - 1
        else
            self.curAdvIndex = 1
        end
        -- self.guangGaoScrollView.gameObject:SetActive(false)
        -- self.guangGaoScrollView.gameObject:SetActive(true)
        if self.moveCountID ~= nil then
            CountDownMgr.Instance:RemoveCountDown(self.moveCountID, false)
        end
        self.isAdvFistMove = true;
        self.moveCountID = CountDownMgr.Instance:CreateCountDown(999999, 4, self.ggmove, self.ggEnd)
        self.advArr[self.curAdvIndex].gameObject:SendMessage("AdvMoveClick")
        for i = 1, #self.adv_all_arr do
            if i ~= self.curAdvIndex then
                self.adv_all_arr[i].color = Color(172 / 255, 172 / 255, 172 / 255)
            else
                self.adv_all_arr[i].color = Color(74 / 255, 132 / 228, 228 / 255)
            end
        end
    end

    UIHelper.BindUIEvnet("Click", advLeftOnClick, self.advLeftBtn.gameObject)

    function advRightOnClick()
        self.advRightBtn.gameObject:SetActive(self.curAdvIndex ~= 2)
        self.advLeftBtn.gameObject:SetActive(true)
        if self.curAdvIndex + 1 <= #self.advArr then
            self.curAdvIndex = self.curAdvIndex + 1
        else
            self.curAdvIndex = #self.advArr
        end
        -- self.guangGaoScrollView.gameObject:SetActive(false)
        -- self.guangGaoScrollView.gameObject:SetActive(true)
        if self.moveCountID ~= nil then
            CountDownMgr.Instance:RemoveCountDown(self.moveCountID, false)
        end
        self.isAdvFistMove = true;
        self.moveCountID = CountDownMgr.Instance:CreateCountDown(999999, 4, self.ggmove, self.ggEnd)
        self.advArr[self.curAdvIndex].gameObject:SendMessage("AdvMoveClick")
        for i = 1, #self.adv_all_arr do
            if i ~= self.curAdvIndex then
                self.adv_all_arr[i].color = Color(172 / 255, 172 / 255, 172 / 255)
            else
                self.adv_all_arr[i].color = Color(74 / 255, 132 / 228, 228 / 255)
            end
        end
    end

    UIHelper.BindUIEvnet("Click", advRightOnClick, self.advRightBtn.gameObject)

    --切换账号
    UIHelper.BindUIEvnet("Click", function()
        UIWinMgr:OpenWindow("LoginWin")
        self:Close()
        self:Destroy()
        SoundModule:SetAllBgVolume(0)
    end, UIUtility.GetChildTransform("wode_shezhi_qhbb_btn", t, true).gameObject)
end

--广告左右点击

function NewGameLoobyWin.ggmove()
    local self = NewGameLoobyWin
    if self.isAdvFistMove or not self.isShow then
        self.isAdvFistMove = false
        return
    end

    if self.curAdvIndex == #self.advArr then
        self.advIsLeft = true
    end

    if self.curAdvIndex == 1 then
        self.advIsLeft = false
    end

    if self.advIsLeft == true then
        self.curAdvIndex = self.curAdvIndex - 1
    else
        self.curAdvIndex = self.curAdvIndex + 1
    end

    self.advRightBtn.gameObject:SetActive(self.curAdvIndex ~= #self.advArr)
    self.advLeftBtn.gameObject:SetActive(self.curAdvIndex ~= 1)
    self.advArr[self.curAdvIndex].gameObject:SendMessage("AdvMoveClick")
    for i = 1, #self.adv_all_arr do
        if i ~= self.curAdvIndex then
            self.adv_all_arr[i].color = Color(172 / 255, 172 / 255, 172 / 255)
        else
            self.adv_all_arr[i].color = Color(74 / 255, 132 / 228, 228 / 255)
        end
    end
    -- self.guangGaoScrollView.gameObject:SetActive(false)
    -- self.guangGaoScrollView.gameObject:SetActive(true)
end

function NewGameLoobyWin.ggEnd()

end

function NewGameLoobyWin:OnClose()
    if self.spineAniCountDown ~= nil then
        CountDownMgr.Instance:RemoveCountDown(self.spineAniCountDown, false)
    end

    self.isShow = false
end

NewGameLoobyWin.secondPassword = ""
function NewGameLoobyWin:Pay_btn()
    --获取已存储的银行信息
    require("NetWork.NetHttp").SendGetRequest("/byr/payment/withdraw/info", function(ok, data)
        if ok then
            print("获取用户提现信息" .. stringify(data))
            for i = 1, #data.data do
                if data.data[i].withdrawMethod == self.all_tixian_type_toggle_index then
                    local withdrawId = data.data[i].withdrawId
                    local data = string.format(
                        '{"amount": %s,"withdrawType":%s,"withdrawId": "%s","secondPassword": "%s"}',
                        (tonumber(self.shop_cur_tixian_xiane_input.value)) * 100, self.all_tixian_type_toggle_index,
                        withdrawId,
                        self.secondPassword)
                    require("NetWork.NetHttp").SendPostRequest_token("/byr/payment/repay",

                        function(ok, data)
                            if ok then
                                UIWinMgr:OpenTextNotice("提交成功,预计2小时到账")
                                self:UpdateUserInfo()
                            else
                                UIWinMgr:OpenTextNotice(data.msg)
                            end
                        end, data)

                    return
                end
            end

            UIWinMgr:OpenTextNotice("请添加提现地址")
        else
            print(stringify(data))
        end
    end)
end

function NewGameLoobyWin:UpdateUserInfo2()
    --获取用户信息
    require("NetWork.NetHttp").SendGetRequest("/byr/user/profile", function(ok, data)
        if ok then
            -- ["phone"] = userdata<userdata: NULL>,
            -- ["status"] = 1,
            -- ["nickName"] = userdata<userdata: NULL>,
            -- ["avatar"] = userdata<userdata: NULL>,
            -- ["agentCode"] = "9RJ4Y3VA",
            -- ["parentAgentCode"] = userdata<userdata: NULL>,
            -- ["email"] = userdata<userdata: NULL>,
            -- ["username"] = "cy1996",
            -- ["userId"] = 102355,
            -- ["havaSecondPassword"] = 0,
            self.user_data = data.data
            --更新推荐码
            self.daili_wddl_tjid_lable.text = data.data.agentCode
            self.daili_wddl_zsid_lable.text = data.data.agentCode
            self.userName_text.text = data.data.username
            self.wode_userName_lable.text = data.data.username
            --更新VIP等级
            self.wode_vip_label.text = data.data.vipLevel
            self.shouye_vip_label.text = data.data.vipLevel

            print("获取用户信息" .. stringify(data))
        else
            print(stringify(data))
        end
    end)
end

-- 1 "刷新成功"
function NewGameLoobyWin:UpdateUserInfo(_status)
    require("NetWork.NetHttp").SendGetRequest("/byr/wallet/balance", function(ok, data)
        if ok then
            self.balance_data = data.data
            print("获取钱包信息" .. stringify(data))
            self.jifen_text.text = "CNY:" .. data.data.gameBalance / 100


            self.wode_userid_lable.text = "ID:" .. data.data.userId
            self.daili_jinbi_lable.text = data.data.gameBalance / 100
            self.shop_tixian_qbye_lable.text = data.data.gameBalance / 100
            self.shop_tixian_syed_lable.text = data.data.withdrawBalance / 100
            self.wode_yue_lable.text = (data.data.gameBalance + data.data.policyBalance) / 100
            self.wode_jifen_lable.text = data.data.withdrawBalance > data.data.gameBalance and
                data.data.gameBalance / 100 or data.data.withdrawBalance / 100
            self.shop_baoxiangui_policyBalance_lable.text = data.data.policyBalance / 100
            self.daili_wddl_down_klqyj_lable.text = data.data.commissionBalance / 100

            if _status == 1 then
                --  UIWinMgr:OpenTextNotice("刷新成功")
            end
        else
            UIWinMgr:OpenTextNotice("更新用户信息失败")
        end
    end)
end

function NewGameLoobyWin:xiaFenUpdate(fun)
    --给所有游戏下分
    require("NetWork.NetHttp").SendGetRequest("/game/api/downAllScore", function(ok, data)
        if ok then
            print("给所有游戏下分" .. stringify(data))
            --获取用户信息
            self:UpdateUserInfo()

            if fun then
                fun()
            end
        else
            UIWinMgr:OpenTextNotice( data.msg)
        end
    end)
end
